package com.example.tliaswebmanagement.Interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//配置类
@Configuration
//注册配置拦截器
public class WebConfig implements WebMvcConfigurer {
    //自定义拦截器对象
    @Autowired
    //private MyInterceptor myInterceptor;
    private TokenInterceptor TokenInterceptor;
    //注册自定义的拦截器对象
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //registry.addInterceptor(myInterceptor).addPathPatterns("/**");//拦截所有请求
        //.excludePathPatterns("/login");//除了登陆路径不拦截
        registry.addInterceptor(TokenInterceptor)
                .addPathPatterns("/**")//设置拦截所有路径
                .excludePathPatterns("/login");

    }
}
